#include <iostream>
#include <vector>
#include <cstdio> 
#include <algorithm>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int >  vec;
typedef pair < int , int > pii;

int read() {
  int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
  while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 2e5 + 10;

int n,mxx,mxy,mnx,mny;
ll ans1,ans2;

struct ball {
    int x,y;
    const bool operator < (const ball b) const { return x < b.x; }
}p[N];

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in; for(int i = 1;i <= n;i++) p[i].x = in,p[i].y = in;
    for(int i = 1;i <= n;i++) if(p[i].x > p[i].y) swap(p[i].x,p[i].y);
    mnx = mny = 1e9;
    for(int i = 1;i <= n;i++) mnx = min(mnx,p[i].x),mxx = max(mxx,p[i].x),mny = min(mny,p[i].y),mxy = max(mxy,p[i].y);
    ans1 = (ll) (mxy - mny) * (mxx - mnx); ll v = mxy - mnx; ans2 = 1e18;
    mny = 1e9; mxy = 0; sort(p + 1,p + n + 1); p[n + 1].x = 1e9;
    for(int i = 1;i <= n;i++) {
	mny = min(mny,p[i].y); mxy = max(mxy,p[i].y);
	ans2 = min(ans2,v * (max(mxy,p[n].x) - min(mny,p[i + 1].x)));
    }
    printf("%lld\n",min(ans1,ans2)); return 0;
} 
